package com.lancoo.ccas52.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lancoo.ccas52.entity.*;
import com.lancoo.ccas52.exception.BizException;
import com.lancoo.ccas52.mapper.*;
import com.lancoo.ccas52.pojo.common.PageInfo;
import com.lancoo.ccas52.pojo.constant.GlobalConstant;
import com.lancoo.ccas52.pojo.dto.CssTaskRoundInfo;
import com.lancoo.ccas52.pojo.vo.*;
import com.lancoo.ccas52.service.*;
import com.lancoo.ccas52.util.PagingUtil;
import com.lancoo.ccas52.util.RedisUtil;
import com.lancoo.ccas52.util.TimeUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;

/**
 * <p>
 * 选课计划 服务实现类
 * </p>
 *
 * @author quin.song
 * @since 2023-01-12
 */
@Service
@Slf4j
public class CssTaskInfoServiceImpl extends ServiceImpl<CssTaskInfoMapper, CssTaskInfo> implements CssTaskInfoService {

    @Resource
    private CssTaskRoundService cssTaskRoundService;
    @Resource
    private CssRangeService cssRangeService;
    @Resource
    private PlanTeachingService planTeachingService;
    @Resource
    private CssPreSelectCourseService cssPreSelectCourseService;
    @Resource
    @Lazy
    private YunBasicService yunBasicService;
    @Resource
    private StudentRetakeService studentRetakeService;
    @Resource
    private MajorService majorService;
    @Resource
    private StudentService studentService;

    @Autowired
    private HttpServletRequest request;

    @Resource
    private CssProhibitStudentMapper cssProhibitStudentMapper;
    @Resource
    private StudentMapper studentMapper;
    @Resource
    private CourseMapper courseMapper;
    @Resource
    private CssPreSelectCourseMapper cssPreSelectCourseMapper;
    @Resource
    private PlanTeachingMapper planTeachingMapper;
    @Resource
    private CssMajorLimitMapper cssMajorLimitMapper;
    @Resource
    private CssRangeMapper cssRangeMapper;
    @Resource
    private TaskInfoMapper taskInfoMapper;
    @Resource
    private TaskToGradeService taskToGradeService;
    @Resource
    private RedisUtil redisUtil;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addCssTask(TaskInfo taskInfo) {
        if (taskInfo.getMainFlow().equals(1) || taskInfo.getMainFlow().equals(2)) {
            //正选任务
            CssTaskInfo cssTaskInfoPri = new CssTaskInfo();
            cssTaskInfoPri.setTaskId(taskInfo.getTaskId())
                    .setCssTaskName(taskInfo.getTermName() + "正式选课计划")
                    .setCssTaskStatus(0)
                    .setType(2);
            this.save(cssTaskInfoPri);

            if (taskInfo.getMainFlow().equals(1)) {
                //预选任务
                CssTaskInfo cssTaskInfoPre = new CssTaskInfo();
                cssTaskInfoPre.setTaskId(taskInfo.getTaskId())
                        .setCssTaskName(taskInfo.getTermName() + "预选课计划")
                        .setCssTaskStatus(0)
                        .setType(1);
                this.save(cssTaskInfoPre);
            }
        }
    }

    @Override
    public CssTaskInfo getCssTaskInfo(Integer taskId, Integer type) {
        //获取选课任务
        CssTaskInfo cssTaskInfo = this.getOne(new LambdaQueryWrapper<CssTaskInfo>().eq(CssTaskInfo::getTaskId, taskId)
                .eq(CssTaskInfo::getType, type));
        if (ObjUtil.isNull(cssTaskInfo)) {
            throw new BizException("该任务不存在选课任务");
        }
        return cssTaskInfo;
    }

    @Override
    public void removeCssInfo(List<Integer> taskIds) {
        List<Integer> cssTaskIds = this.lambdaQuery().in(CssTaskInfo::getTaskId, taskIds).list().stream().map(CssTaskInfo::getCssTaskId).collect(Collectors.toList());
        if (CollUtil.isNotEmpty(cssTaskIds)) {
            cssTaskRoundService.remove(new LambdaQueryWrapper<CssTaskRound>().in(CssTaskRound::getCssTaskId, cssTaskIds));
            cssProhibitStudentMapper.delete(new LambdaQueryWrapper<CssProhibitStudent>().in(CssProhibitStudent::getCssTaskId, cssTaskIds));
        }
        cssRangeService.remove(new LambdaQueryWrapper<CssRange>().in(CssRange::getTaskId, taskIds));

        cssMajorLimitMapper.delete(new LambdaQueryWrapper<CssMajorLimit>().in(CssMajorLimit::getTaskId, taskIds));
        cssPreSelectCourseMapper.delete(new LambdaQueryWrapper<CssPreSelectCourse>().in(CssPreSelectCourse::getTaskId, taskIds));
        this.lambdaUpdate().in(CssTaskInfo::getTaskId, taskIds).remove();
    }

    @Override
    public List<CssTaskRoundInfo> getCssTaskBySchool(GetCssTask getCssTask) {
        List<CssTaskRoundInfo> allRound = getRound();
        List<CssTaskRoundInfo> returnRound = new ArrayList<>();

        Iterator<CssTaskRoundInfo> iterator = allRound.iterator();
        while (iterator.hasNext()) {
            CssTaskRoundInfo cssTaskRoundInfo = iterator.next();
            //根据前端筛选条件过滤
            if (StrUtil.isNotBlank(getCssTask.getSchoolId()) && !cssTaskRoundInfo.getSchoolId().equals(getCssTask.getSchoolId())) {
                iterator.remove();
                continue;
            }
            if (ObjUtil.isNotNull(getCssTask.getType()) && !cssTaskRoundInfo.getType().equals(getCssTask.getType())) {
                iterator.remove();
                continue;
            }
            if (StrUtil.isNotBlank(getCssTask.getKeyWord()) && !cssTaskRoundInfo.getCssTaskName().contains(getCssTask.getKeyWord())) {
                iterator.remove();
                continue;
            }
            //任务所属年级过滤
            if (!cssTaskRoundInfo.getTaskToGradeIds().contains(getCssTask.getGradeId())) {
                iterator.remove();
                continue;
            }
            //根据学院、年级范围过滤。预选、退选不需要过滤，所有学生都要显示。
            if (cssTaskRoundInfo.getType().equals(2) && !cssTaskRoundInfo.getSelectRound().equals(3)) {
                if (cssTaskRoundInfo.getCssRanges().stream().noneMatch(cssRange -> (cssRange.getOptionIdentify().equals(1) && cssRange.getOptionId().equals(getCssTask.getCollegeId()))) ||
                        cssTaskRoundInfo.getCssRanges().stream().noneMatch(cssRange -> (cssRange.getOptionIdentify().equals(2) && cssRange.getOptionId().equals(getCssTask.getGradeId())))) {
                    iterator.remove();
                }
            }
        }
        //全部选课轮次，根据选课任务id分组。
        Map<Integer, List<CssTaskRoundInfo>> roundMap = allRound.stream().collect(Collectors.groupingBy(CssTaskRoundInfo::getCssTaskId));
        roundMap.forEach((k, v) -> {
            /*
                根据 轮次阶段倒序排序。然后根据时间计算状态
                1.进行中  直接保留
                2.已结束  直接保留
                3.待开始->进行中 保留后者
                4.待开始->已结束 保留前者
                5.待开始->待开始 保留后者
                 */
            v.sort(Comparator.comparing(CssTaskRoundInfo::getSelectRound).thenComparing(CssTaskRoundInfo::getStage).reversed());
            CssTaskRoundInfo firstCssTaskRound = v.get(0);
            int status = TimeUtils.getStatus(firstCssTaskRound.getBeginTime(), firstCssTaskRound.getEndTime());
            for (int i = 1; i < v.size(); i++) {
                CssTaskRoundInfo currentCssTaskRound = v.get(i);
                int currentStatus = TimeUtils.getStatus(currentCssTaskRound.getBeginTime(), currentCssTaskRound.getEndTime());
                if (status == 1 || status == 2 || (status == 3 && currentStatus == 1)) {
                    break;
                }
                if (status == 3 && currentStatus == 3) {
                    firstCssTaskRound = currentCssTaskRound;
                    continue;
                }
                if (status == 3 && currentStatus == 2) {
                    status = currentStatus;
                    firstCssTaskRound = currentCssTaskRound;
                    break;
                }
            }
            firstCssTaskRound.setState(status);
            returnRound.add(firstCssTaskRound);
        });
        return returnRound;
    }

    public List<CssTaskRoundInfo> getRound() {
        if (redisUtil.hasKey(GlobalConstant.REDIS_ROUND_KEY)) {
            return (List<CssTaskRoundInfo>) redisUtil.get(GlobalConstant.REDIS_ROUND_KEY);
        } else {
            List<CssTaskRoundInfo> allRoundInfo = cssRangeMapper.getAllRoundInfo();
            //年级
            Map<Integer, List<TaskToGrade>> gradeMap = taskToGradeService.lambdaQuery().list()
                    .stream().collect(Collectors.groupingBy(TaskToGrade::getTaskId));
            //获取范围
            Map<Integer, List<CssRange>> rangeMap = cssRangeService.lambdaQuery().list().stream()
                    .collect(Collectors.groupingBy(CssRange::getRoundId));
            allRoundInfo.forEach(a -> {
                List<CssRange> cssRanges = rangeMap.get(a.getId());
                List<TaskToGrade> taskToGrades = gradeMap.get(a.getTaskId());
                if (CollUtil.isNotEmpty(cssRanges)) {
                    a.setCssRanges(cssRanges);
                }
                if (CollUtil.isNotEmpty(taskToGrades)) {
                    a.setTaskToGradeIds(taskToGrades.stream().map(TaskToGrade::getGradeId).collect(Collectors.toList()));
                }
            });
            redisUtil.set(GlobalConstant.REDIS_ROUND_KEY, allRoundInfo, 60 * 60 * 24 * 7);
            return allRoundInfo;
        }
    }

    @Override
    public CssTaskInfo updateCssTaskInfo(CssTaskInfo cssTaskInfo) {
        this.updateById(cssTaskInfo);
        //设置选课轮次时同步重修学生
        TaskInfo taskInfo = taskInfoMapper.selectById(cssTaskInfo.getTaskId());
        if (ObjUtil.isNotNull(taskInfo)) {
            boolean exists = studentRetakeService.lambdaQuery().eq(StudentRetake::getSchoolId, taskInfo.getSchoolId())
                    .eq(StudentRetake::getTerm, taskInfo.getTerm()).exists();
            if (!exists) {
                yunBasicService.syncRetakeStudent(cssTaskInfo.getTaskId(), taskInfo.getSchoolId(), taskInfo.getTerm());
            }
        }
        redisUtil.del(GlobalConstant.REDIS_ROUND_KEY);
        return cssTaskInfo;
    }

    @Override
    public Boolean getEarliestRound(Integer cssTaskId) {
        CssTaskRound cssTaskRound = cssTaskRoundService.lambdaQuery()
                .eq(CssTaskRound::getCssTaskId, cssTaskId).orderByAsc(CssTaskRound::getBeginTime).last("limit 1").one();
        if (ObjUtil.isNotNull(cssTaskRound)) {
            return cssTaskRound.getBeginTime().isAfter(LocalDateTime.now());
        }
        return true;
    }

    @Override
    public Boolean removeUselessRound(Integer cssTaskId, List<Integer> selectRound) {
        if (CollUtil.isEmpty(selectRound)) {
            return true;
        }
        List<CssTaskRound> cssTaskRounds = cssTaskRoundService.lambdaQuery().eq(CssTaskRound::getCssTaskId, cssTaskId).in(CssTaskRound::getSelectRound, selectRound).list();
        List<Integer> roundIds = cssTaskRounds.stream().map(CssTaskRound::getId).collect(Collectors.toList());
        if (CollUtil.isNotEmpty(roundIds)) {
            cssRangeService.lambdaUpdate().in(CssRange::getRoundId, roundIds).remove();
            cssTaskRoundService.lambdaUpdate().in(CssTaskRound::getId, roundIds).remove();
        }
        redisUtil.del(GlobalConstant.REDIS_ROUND_KEY);
        return true;
    }

    @Override
    public CssTaskRound addOrUpdateCssTaskRound(CssTaskRound cssTaskRound) {
        cssTaskRoundService.saveOrUpdate(cssTaskRound);
        //获取选课任务 判断是否是预选、正选
        CssTaskInfo cssTaskInfo = this.getById(cssTaskRound.getCssTaskId());

        // 发送消息
        String userId = request.getHeader("userId");
        String userName = request.getHeader("userName");
        String authorization = request.getHeader("Authorization");

        String module = "";
        if (cssTaskInfo.getType() == 1) {
            module = "预选";
        } else if (cssTaskInfo.getType() == 2 && cssTaskRound.getSelectRound() == 1) {
            module = "正选";
        } else if (cssTaskInfo.getType() == 2 && cssTaskRound.getSelectRound() == 2) {
            module = "补选";
        } else if (cssTaskInfo.getType() == 2 && cssTaskRound.getSelectRound() == 3) {
            module = "退选";
        }
        if (StrUtil.isNotBlank(module) && ObjUtil.isNotNull(cssTaskRound.getBeginTime()) && ObjUtil.isNotNull(cssTaskRound.getEndTime())) {
            yunBasicService.sendSelectCourseStartMsg(cssTaskRound.getBeginTime(), cssTaskRound.getEndTime(), cssTaskInfo.getTaskId(), module, userId, userName, authorization);
        }
        redisUtil.del(GlobalConstant.REDIS_ROUND_KEY);

        return cssTaskRound;
    }

    @Override
    public List<CssTaskRound> getCssTaskRound(Integer cssTaskId, Integer selectRound) {
        List<CssTaskRound> cssTaskRounds = cssTaskRoundService.lambdaQuery()
                .eq(CssTaskRound::getCssTaskId, cssTaskId)
                .eq(CssTaskRound::getSelectRound, selectRound).list().stream()
                .sorted(Comparator.comparing(CssTaskRound::getStage)).collect(Collectors.toList());
        return cssTaskRounds;
    }

    @Override
    public Boolean removeCssTaskRound(Integer id) {
        cssTaskRoundService.removeById(id);
        //删除选课范围
        cssRangeService.remove(new LambdaQueryWrapper<CssRange>().eq(CssRange::getRoundId, id));
        redisUtil.del(GlobalConstant.REDIS_ROUND_KEY);
        return true;
    }

    @Override
    public List<CssRange> setRange(List<CssRange> cssRanges, Integer optionIdentify, Integer roundId) {
        //删除原来的设置
        if (ObjUtil.isNotNull(optionIdentify)) {
            cssRangeService.remove(new LambdaQueryWrapper<CssRange>()
                    .eq(CssRange::getRoundId, roundId).eq(CssRange::getOptionIdentify, optionIdentify));
        } else {
            cssRangeService.remove(new LambdaQueryWrapper<CssRange>()
                    .eq(CssRange::getRoundId, roundId).ne(CssRange::getOptionIdentify, 3));
        }
        cssRangeService.saveBatch(cssRanges);
        redisUtil.del(GlobalConstant.REDIS_ROUND_KEY);
        return cssRanges;
    }

    @Override
    public List<CssRange> getRange(List<Integer> roundIds, Integer optionIdentify) {
        if (CollUtil.isEmpty(roundIds)) {
            return Lists.newArrayList();
        }
        List<CssRange> cssRanges = cssRangeService.lambdaQuery()
                .in(CssRange::getRoundId, roundIds)
                .eq(ObjUtil.isNotNull(optionIdentify), CssRange::getOptionIdentify, optionIdentify).list();
        return cssRanges;
    }

    @Override
    public PageInfo<CoursePlanDto> getCourseAndPreByConditions(Integer taskId, IPage page, Integer studyNature, String courseTypeId, Integer courseNature, Integer majorProp, String collegeId, String keyWord, Integer state) {
        IPage<CoursePlanDto> courseAndPreSelect = courseMapper.getCourseAndPreSelect(taskId, page, studyNature, courseTypeId, courseNature, majorProp, collegeId, keyWord, state);
        return PagingUtil.formatPageResult(courseAndPreSelect);
    }

    @Override
    public PreCourseConfiguredVo getPreCourseSet(Integer taskId) {
        PreCourseConfiguredVo preCourseConfiguredVo = courseMapper.getPreCourseConfiguredVo(taskId);
        preCourseConfiguredVo.setTotal(preCourseConfiguredVo.getConfigured() + preCourseConfiguredVo.getNoConfigured());
        return preCourseConfiguredVo;
    }

    @Override
    public PageInfo<CoursePlanDto> getFormalCourseBySelect(Integer taskId, IPage page, Integer studyNature, String courseTypeId, Integer courseNature, Integer majorProp, String collegeId, String keyWord) {
        IPage<CoursePlanDto> formalCourseBySelect = courseMapper.getFormalCourseBySelect(taskId, page, studyNature, courseTypeId, courseNature, majorProp, collegeId, keyWord);
        return PagingUtil.formatPageResult(formalCourseBySelect);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean addPreSelectCourse(Integer taskId, int preState, List<PreCourseInput> preList) {
        //获取选课任务
        CssTaskInfo cssTaskInfo = this.getOne(new LambdaQueryWrapper<CssTaskInfo>().eq(CssTaskInfo::getTaskId, taskId)
                .eq(CssTaskInfo::getType, 1));
        if (ObjUtil.isNull(cssTaskInfo)) {
            throw new BizException("该任务不存在选课任务");
        }
        //批量设置预选课程
        if (preState == 1) {
            List<CssPreSelectCourse> list = new ArrayList<>();
            preList.forEach(a -> {
                CssPreSelectCourse cssPreSelectCourse = new CssPreSelectCourse();
                BeanUtil.copyProperties(a, cssPreSelectCourse);
                cssPreSelectCourse.setTaskId(taskId);
                cssPreSelectCourse.setCssTaskId(cssTaskInfo.getCssTaskId());
                cssPreSelectCourse.setOperationStatus(1);
                list.add(cssPreSelectCourse);
            });
            cssPreSelectCourseMapper.addBatch(list);
        } else {
            //批量取消（获取不到id,只能一条一条删除.优化的话可以拆成两个接口）
            preList.forEach(a -> {
                cssPreSelectCourseMapper.delete(new LambdaQueryWrapper<CssPreSelectCourse>().eq(CssPreSelectCourse::getTaskId, taskId)
                        .eq(CssPreSelectCourse::getCourseId, a.getCourseId())
                        .eq(CssPreSelectCourse::getStudyNature, a.getStudyNature()));
            });
        }
        return true;
    }

    @Override
    public PageInfo<CoursePlanDto> getPreByConditions(Integer taskId, IPage page, Integer studyNature, String courseTypeId, Integer courseNature, Integer majorProp, String collegeId, String keyWord, Integer state) {
        IPage<CoursePlanDto> preSelect = courseMapper.getPreSelect(taskId, page, studyNature, courseTypeId, courseNature, majorProp, collegeId, keyWord, state);
        //填充上课人数，预计效率很慢。建议前端不显示
        for (CoursePlanDto record : preSelect.getRecords()) {
            //培养计划修读学生
            Integer studentNumCourse = planTeachingService.getStudentNumByCourseAndNature(1, record.getCourseId(), record.getStudyNature(), null).size();
            //重修学生
//            int studentNumRetake = studentRetakeService.getStudentRetakeByCourse(record.getCourseId(), 1, studyNature,null).size();
            record.setStudentNumPlan(studentNumCourse);
//            record.setStudentNumRetake(studentNumRetake);
            record.setStudentNum(studentNumCourse);
        }
        return PagingUtil.formatPageResult(preSelect);
    }

    @Override
    public boolean setSelectState(Integer preSelectId, Integer operationStatus) {
        cssPreSelectCourseService.lambdaUpdate().eq(CssPreSelectCourse::getId, preSelectId).set(CssPreSelectCourse::getOperationStatus, operationStatus).update();
        return true;
    }

    @Override
    public int addProhibitStudent(List<CssProhibitStudentInput> prohibitList) {
        List<CssProhibitStudent> cssProhibitStudentList = BeanUtil.copyToList(prohibitList, CssProhibitStudent.class);
        return cssProhibitStudentMapper.addBatch(cssProhibitStudentList);

    }

    @Override
    public int removeProhibitStudent(List<Long> prohibitIds) {
        return cssProhibitStudentMapper.delete(new LambdaQueryWrapper<CssProhibitStudent>().in(CssProhibitStudent::getStudentId, prohibitIds));
    }

    @Override
    public Student updatePlanStudent(StudentLimitInput studentLimitInput) {
//        List<PlanTeachingStudent> planTeachingStudents = BeanUtil.copyToList(studentLimitInput, PlanTeachingStudent.class);
        //todo 根据修读性质更新修改
        Student student = new Student();
        BeanUtil.copyProperties(studentLimitInput, student);
        studentMapper.updateById(student);
        return student;
    }

    @Override
    public PageInfo<Major> getMajorList(Integer taskId, Integer studyNature, String collegeId, String majorId, String gradeId, String keyWord, Integer state, Integer currentPage, Integer pageSize) {
        Page<Major> page = new Page<>(currentPage, pageSize);
        Page<Major> majorList = planTeachingMapper.getMajorJoinPlan(page, taskId, studyNature, collegeId, majorId, gradeId, keyWord, state);
        return PagingUtil.formatPageResult(majorList);
    }

    @Override
    public Boolean addOrUpdateBatchMajorLimit(List<MajorLimitInput> majorLimitInputList) {
        if (CollUtil.isEmpty(majorLimitInputList)) {
            log.info("参数为空，majorLimitInputList{}", majorLimitInputList);
            return false;
        }
        List<Major> majorList = BeanUtil.copyToList(majorLimitInputList, Major.class);
        majorService.updateBatchById(majorList);
        //修改对应学生的选课上限
        majorLimitInputList.forEach(a -> {
            Major major = majorService.getById(a.getMajorId());
            if (ObjUtil.isNotNull(major)) {
                studentService.lambdaUpdate().set(Student::getCourseLimitMain, major.getCourseLimitMain())
                        .set(Student::getCreditLimitMain, major.getCreditLimitMain())
                        .set(Student::getCourseLimitMinor, major.getCourseLimitMinor())
                        .set(Student::getCreditLimitMinor, major.getCreditLimitMinor())
                        .set(Student::getOnlyMajor, major.getOnlyMajor())
                        .eq(Student::getTaskId, major.getTaskId())
                        .eq(Student::getGradeId, major.getGradeId())
                        .eq(Student::getMajorId, major.getBaseMajorId())
                        .update();
            }
        });
        return true;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean unifiedMajorLimit(CssTaskInfo cssTaskInfo) {
        this.updateById(cssTaskInfo);
        //更新专业限制
        majorService.lambdaUpdate().set(Major::getCourseLimitMain, cssTaskInfo.getCourseLimitMain())
                .set(Major::getCreditLimitMain, cssTaskInfo.getCreditLimitMain())
                .set(Major::getCourseLimitMinor, cssTaskInfo.getCourseLimitMinor())
                .set(Major::getCreditLimitMinor, cssTaskInfo.getCreditLimitMinor())
                .set(Major::getOnlyMajor, cssTaskInfo.getOnlyMajor())
                .set(Major::getStateLimit, 2)
                .eq(Major::getTaskId, cssTaskInfo.getTaskId()).update();
        //修改学生的选课上限
        studentService.lambdaUpdate().set(Student::getCourseLimitMain, cssTaskInfo.getCourseLimitMain())
                .set(Student::getCreditLimitMain, cssTaskInfo.getCreditLimitMain())
                .set(Student::getCourseLimitMinor, cssTaskInfo.getCourseLimitMinor())
                .set(Student::getCreditLimitMinor, cssTaskInfo.getCreditLimitMinor())
                .set(Student::getOnlyMajor, cssTaskInfo.getOnlyMajor())
                .eq(Student::getTaskId, cssTaskInfo.getTaskId()).update();
        return true;
    }


}
